/*
编写 : Hexh
时间 : 2012-11-27 14:38:42
*/
using System;
using System.Collections;
using System.Text;
using HMIS.FrameWork.DomainBase;
using HMIS.FrameWork;
using HMIS.Infrastructure.Core.Authority;
using HMIS.Infrastructure.Core.Entities;

namespace FSBS.Core.Entity
{
    /// <summary>
    ///	the entity of FsbsQmTrsf
    /// </summary>
    public class FsbsQmTrsf : InputItem
    {

        #region Public Properties

        /// <summary>
        /// 调拨调派类型
        /// </summary>
        public virtual string Trtype { get; set; }

        /// <summary>
        /// 经办人ID
        /// </summary>
        public virtual string Opusid { get; set; }

        /// <summary>
        /// 经办人
        /// </summary>
        public virtual HospUser OpUser { get; set; }

        /// <summary>
        /// 调出仓库ID
        /// </summary>
        public virtual string Otdpid { get; set; }

        /// <summary>
        /// 调出仓库
        /// </summary>
        public virtual Department OuDept { get; set; }

        /// <summary>
        /// 调出仓管ID
        /// </summary>
        public virtual string Oudpus { get; set; }

        /// <summary>
        /// 调出仓管
        /// </summary>
        public virtual HospUser OudpUser { get; set; }

        /// <summary>
        /// 调入仓库ID
        /// </summary>
        public virtual string Indpid { get; set; }

        /// <summary>
        /// 调入仓库
        /// </summary>
        public virtual Department InDept { get; set; }

        /// <summary>
        /// 调入仓管ID
        /// </summary>
        public virtual string Indpus { get; set; }

        /// <summary>
        /// 调入仓管
        /// </summary>
        public virtual HospUser IndpUser { get; set; }

        /// <summary>
        /// 预期出发时间
        /// </summary>
        public virtual DateTime Exoutm { get; set; }

        /// <summary>
        /// 预期到达时间
        /// </summary>
        public virtual DateTime Exartm { get; set; }

        /// <summary>
        /// 实际出发时间
        /// </summary>
        public virtual DateTime? Acoutm { get; set; }

        /// <summary>
        /// 实际到达时间
        /// </summary>
        public virtual DateTime? Acartm { get; set; }

        /// <summary>
        /// 事由
        /// </summary>
        public virtual string Reason { get; set; }

        /// <summary>
        /// 审批流程ID
        /// </summary>
        public virtual string ApprHisId { get; set; }

        /// <summary>
        /// 审批流程
        /// </summary>
        public virtual InfraApproveHis ApprHis { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public virtual CarTransferState Trstate { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public virtual DateTime? SmsTime { get; set; }

        /// <summary>
        /// 调拨车辆清单
        /// </summary>
        public virtual Iesi.Collections.Generic.ISet<FsbsQmCrif> Cars { get; set; }

        #endregion

        #region Public Method

        /// <summary>
        /// 生成短信信息
        /// </summary>
        /// <returns></returns>
        public virtual string ToSmsString()
        {
            string trType = this.Trtype == "trtype01" ? "商品车调拨" : "商品车派车";
            string smsStr = "[" + trType + "]\n经办:" + this.OpUser.Name + "," + this.OpUser.Mobitl + "\n事由:" + this.Reason
                + "\n出发:" + this.Exoutm;
            if (this.Trtype == "trtype01") // "商品车调拨"
                smsStr = smsStr + "\n到达:" + this.Exartm + "\n调出:" + this.OuDept.Name + "\n调入:" + this.InDept.Name;
            else
                smsStr = smsStr + "\n返回:" + this.Exartm + "\n展场:" + this.OuDept.Name;

            //车辆清单信息
            string carList = "\n[车辆:" + this.Cars.Count + "]";
            int index = 1;
            foreach (FsbsQmCrif car in this.Cars)
            {
                carList = carList + "\n" + index.ToString() + "." + car.ToSmsString();
                index++;
            }
            return smsStr + carList;
        }

        #endregion
    }

    /// <summary>
    /// 调派状态
    /// </summary>
    public enum CarTransferState
    {
        /// <summary>
        /// 待提交
        /// </summary>
        [EnumDescription("待提交")]
        Editing = 0,

        /// <summary>
        /// 待审批
        /// </summary>
        [EnumDescription("待审批")]
        Appling = 1,

        /// <summary>
        /// 否决
        /// </summary>
        [EnumDescription("否决")]
        Refused = 9,

        /// <summary>
        /// 已审批
        /// </summary>
        [EnumDescription("已审批")]
        Agreed = 2,

        /// <summary>
        /// 已出发
        /// </summary>
        [EnumDescription("已出发")]
        Processing = 3,

        /// <summary>
        /// 已接收
        /// </summary>
        [EnumDescription("已接收")]
        Returned = 4,

        /// <summary>
        /// 已接收
        /// </summary>
        [EnumDescription("已入库")]
        Stored = 5
    }
}
